#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main() {
	int n;
	char ch;

	cin >> ch >> n;

	vector<vector<char>> a(n, vector<char>(n));

	for (int i = 0; i < n; i++)
		for (int j = 0; j < n; j++)
			cin >> a[i][j];

	vector<vector<char>> b(n, vector<char>(n));

	for (int i = 0; i < n; i++)
		for (int j = 0; j < n; j++)
			b[i][j] = a[i][j];

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++)
			cout << b[i][j];
		cout << endl;
	}

	for (int i = 0; i < n; i++) {
		for (int j = 0, k = n - 1; j < k; j++, k--) {
			swap(b[i][j], b[i][k]);
		}
	}

	for (int i = 0; i < n; i++) {
		for (int j = 0, k = n - 1; j < k; j++, k--) {
			swap(b[j][i], b[k][i]);
		}
	}

	if (a == b)
		cout << "bu yong dao le\n";

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++)
			cout << b[i][j];
		cout << endl;
	}
	return 0;
}
